package logbook.utils;

import java.io.IOException;
import java.nio.file.Path;

import org.apache.commons.io.FileUtils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

public class JsonUtils {

    private JsonUtils() {
    }

    public static JSONObject readJsonObjectFromFile(Path jsonPath) throws IOException {
        String jsonStr = FileUtils.readFileToString(jsonPath.toFile());
        return JSON.parseObject(jsonStr);
    }

    public static JSONArray readJsonArrayFormFile(Path jsonPath) throws IOException {
        String jsonStr = FileUtils.readFileToString(jsonPath.toFile());
        return JSON.parseArray(jsonStr);
    }
}
